import {Button, Space} from "antd";

export const useBooksColumns = (editBook,deleteBook) => {
    const columns = [
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            align: 'center'

        },
        {
            title: '书籍名称',
            dataIndex: 'bookname',
            key: 'bookname',
            align: 'center'
        },
        {
            title: '作者',
            dataIndex: 'author',
            key: 'author',
            align: 'center'
        },
        {
            title: '出版社',
            dataIndex: 'publisher',
            key: 'publisher',
            align: 'center'
        },
        {
            title: '创建时间',
            dataIndex: 'createdAt',
            key: 'createdAt',
            align: 'center'
        },
        {
            title: '更新时间',
            dataIndex: 'updatedAt',
            key: 'updatedAt',
            align: 'center'
        },
        {
            title: 'Action',
            key: 'action',
            render: (_, record) => (
                <Space size="middle">
                    <Button type="primary" onClick={() => editBook(record)}>编辑</Button>
                    <Button type="primary" danger onClick={() => deleteBook(record)}>删除</Button>
                </Space>
            ),
        },
    ]

    return {
        columns
    }
}


export const useModalFooter = (handleCancel, handleConfirm) => {
    const modalFooter = [<Button key="back" onClick={handleCancel}>取消</Button>, <Button key="submit" type="primary" onClick={handleConfirm}>确定</Button>]
    return {
        modalFooter
    }
}
